// Transport.h: interface for the CTransport class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_TRANSPORT_H__8484B20E_DA63_4A13_B6C0_5888121A94EF__INCLUDED_)
#define AFX_TRANSPORT_H__8484B20E_DA63_4A13_B6C0_5888121A94EF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "osplatform.h"
#include "mystring.h"
class CSIPMessage;
class CSIPStack;
class CTransport  
{
public:	
	
	typedef enum 
	{
		Unknown = 0,
		UDP,
		TCP,
		TLS,
		SCTP,
		DCCP,
		MAX_TRANSPORT
	} TYPE;
	struct Tuple{
		Tuple(){type = UDP;ipv4.s_addr = 0;port = 0;transport = NULL;};
		int type;
		in_addr ipv4;
	#ifdef IPV6_SUPPORT
		mystring ip_address;
	#endif
		uint16 port;
		CTransport *transport;
	};
	
	TYPE GetType(){return m_nType;};
	uint16 GetPort(){return m_nLocalPort;};
	mystring GetHost(){return m_strLocalIP;};
    CTransport(CSIPStack* pStack, const mystring& ip, uint16 port);
	virtual ~CTransport();
	static void *RecvProc(void *argc);
	static void *SendProc(void *argc);
	virtual bool IsOK(){return false;};
	virtual bool SendMsg(CSIPMessage &Msg) = 0;
	virtual void DoSend() = 0;
	virtual void DoRecv() = 0;
	virtual CSIPMessage *RecvMsg() = 0;
protected:
	bool		m_bRunning;
	pthread_t	m_hRecvThread;
	pthread_t	m_hSendThread;
    CSIPStack* 	m_pSIPStack;	//pointer to sip stack
	mystring 	m_strLocalIP;
    uint16  	m_nLocalPort;
    TYPE 		m_nType;		//type of lower level tranport protocol, udp? tcp?...
};

#endif // !defined(AFX_TRANSPORT_H__8484B20E_DA63_4A13_B6C0_5888121A94EF__INCLUDED_)
